package com.netsmart.util;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.netsmart.bean.Admin;

public class SessionUtil {

    public static Admin sessionAdmin;

    public static Admin getSessionAdmin() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
                .getRequest();
        sessionAdmin = (Admin) request.getSession().getAttribute("admin");
        return sessionAdmin;
    }

    public static void setSessionAdmin(Admin sessionAdmin) {
        SessionUtil.sessionAdmin = sessionAdmin;
    }
    
    public static void init() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
                .getRequest();
        sessionAdmin = (Admin) request.getSession().getAttribute("admin");
    }
    
}
